package com.practice.mybatis.v2.config;

import java.util.HashMap;
import java.util.Map;

import com.practice.mybatis.v1.Test;

public class MapperRegistory {
	
	private static final Map<String, MapperData<?>> mapperRegistory = new HashMap<>();
	
	public MapperRegistory() {
		mapperRegistory.put("com.practice.mybatis.v2.config.mapper.TestMapper.selectByPrimaryKey", 
				new MapperData<>("select * from test where id = '%d'", Test.class));
	}
	
	public MapperData get(String namespace) {
		return mapperRegistory.get(namespace);
	}
	
	public class MapperData<T> {
		private String sql;
		private Class<T> type;
		
		public MapperData(String sql, Class<T> type) {
			this.sql = sql;
			this.type = type;
		}

		public String getSql() {
			return sql;
		}

		public void setSql(String sql) {
			this.sql = sql;
		}

		public Class<T> getType() {
			return type;
		}

		public void setType(Class<T> type) {
			this.type = type;
		}
	}

}
